# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer:
pkgname=adapta-gtk-theme
pkgver=3.95.0.11
pkgrel=2
pkgdesc="An adaptive Gtk+ theme based on Material Design Guidelines"
url="https://github.com/adapta-project/adapta-gtk-theme"
arch="noarch !s390x" # Fails to build on s390x and I doubt anyone actually uses it on s390x
license="GPL-2.0-or-later"
makedepends="autoconf automake inkscape gdk-pixbuf-dev glib-dev libxml2-dev sassc
	parallel bash"
subpackages="
	adapta:_adapta:noarch
	adapta-xfwm4:_adapta_xfwm4:noarch
	adapta-telegram:_adapta_telegram:noarch
	adapta-openbox:_adapta_openbox:noarch
	adapta-cinnamon:_adapta_cinnamon:noarch
	adapta-gnome:_adapta_gnome:noarch
	adapta-gtk3:_adapta_gtk3:noarch
	adapta-gtk2:_adapta_gtk2:noarch

	adapta-eta:_adapta_eta:noarch
	adapta-eta-gtk3:_adapta_eta_gtk3:noarch
	adapta-eta-gtk2:_adapta_eta_gtk2:noarch
	adapta-eta-gnome:_adapta_eta_gnome:noarch
	adapta-eta-telegram:_adapta_eta_telegram:noarch

	adapta-nokto:_adapta_nokto:noarch
	adapta-nokto-gtk3:_adapta_nokto_gtk3:noarch
	adapta-nokto-gtk2:_adapta_nokto_gtk2:noarch
	adapta-nokto-gnome:_adapta_nokto_gnome:noarch
	adapta-nokto-cinnamon:_adapta_nokto_cinnamon:noarch
	adapta-nokto-telegram:_adapta_nokto_telegram:noarch
	adapta-nokto-openbox:_adapta_nokto_openbox:noarch
	adapta-nokto-xfwm4:_adapta_nokto_xfwm4:noarch

	adapta-nokto-eta:_adapta_nokto_eta:noarch
	adapta-nokto-eta-gtk3:_adapta_nokto_eta_gtk3:noarch
	adapta-nokto-eta-gtk2:_adapta_nokto_eta_gtk2:noarch
	adapta-nokto-eta-gnome:_adapta_nokto_eta_gnome:noarch
	adapta-nokto-eta-telegram:_adapta_nokto_eta_telegram:noarch
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/adapta-project/adapta-gtk-theme/archive/$pkgver.tar.gz"

prepare() {
	default_prepare
	NOCONFIGURE=1 ./autogen.sh
}

build() {
	./configure \
		--prefix=/usr \
		--enable-parallel \
		--enable-gnome \
		--enable-cinnamon \
		--disable-flashback \
		--enable-xfce \
		--enable-mate \
		--enable-openbox \
		--disable-chrome_legacy \
		--disable-plank \
		--enable-telegram
	make
}

package() {
	make DESTDIR="$pkgdir" install

	rm -f "$pkgdir"/usr/share/themes/Adapta/COPYING
	rm -f "$pkgdir"/usr/share/themes/Adapta/LICENSE*

	rm -rf "$pkgdir"/usr/share/themes/*/metacity-1
}

_mv() {
	mkdir -p "$subpkgdir"/usr/share/themes/"$1"
	mv "$pkgdir"/usr/share/themes/"$1"/"$2" \
		"$subpkgdir"/usr/share/themes/"$1"

	# This will fail a lot
	rmdir -p "$pkgdir"/usr/share/themes/"$1" 2>/dev/null || :
}

_adapta() {
	depends="ttf-roboto font-noto"
	pkgdesc="Adapta theme metapackage"
	mkdir -p "$subpkgdir"
	_mv Adapta index.theme
}

_adapta_xfwm4() {
	depends=""
	pkgdesc="Adapta theme for XFCE4 Window Manager"
	install_if="adapta=$pkgver-r$pkgrel xfwm4"
	_mv Adapta xfwm4
	_mv Adapta xfce-notify-4.0
}

_adapta_telegram() {
	depends=""
	pkgdesc="adapta theme for Telegram"
	install_if="Adapta=$pkgver-r$pkgrel telegram-desktop"
	_mv Adapta telegram
}

_adapta_openbox() {
	depends=""
	pkgdesc="Adapta theme for Openbox 3"
	install_if="adapta=$pkgver-r$pkgrel openbox"
	_mv Adapta openbox-3
}

_adapta_cinnamon() {
	depends=""
	pkgdesc="Adapta theme for Cinnamon"
	install_if="adapta=$pkgver-r$pkgrel cinnamon"
	_mv Adapta cinnamon
}

_adapta_gnome() {
	depends=""
	pkgdesc="Adapta theme for GNOME Shell"
	install_if="adapta=$pkgver-r$pkgrel gnome-shell"
	_mv Adapta gnome-shell
	_mv Adapta gedit
}

_adapta_gtk3() {
	pkgdesc="Adapta theme for GTK+3"
	install_if="adapta=$pkgver-r$pkgrel gtk+3.0"
	_mv Adapta gtk-3.0
	_mv Adapta gtk-3.22
	_mv Adapta gtk-3.24
}

_adapta_gtk2() {
	depends="gtk-murrine-engine"
	pkgdesc="Adapta theme for GTK+2"
	install_if="adapta=$pkgver-r$pkgrel gtk+2.0"
	_mv Adapta gtk-2.0
}

_adapta_eta() {
	depends="ttf-roboto font-noto"
	pkgdesc="Adapta Eta theme metapackage"
	mkdir -p "$subpkgdir"
	_mv Adapta-Eta index.theme
}

_adapta_eta_gtk3() {
	pkgdesc="Adapta Eta theme for GTK+3"
	install_if="adapta-eta=$pkgver-r$pkgrel gtk+3.0"
	_mv Adapta-Eta gtk-3.0
	_mv Adapta-Eta gtk-3.22
	_mv Adapta-Eta gtk-3.24
}

_adapta_eta_gtk2() {
	depends="gtk-murrine-engine"
	pkgdesc="Adapta Eta theme for GTK+2"
	install_if="adapta-eta=$pkgver-r$pkgrel gtk+2.0"
	_mv Adapta-Eta gtk-2.0
}

_adapta_eta_gnome() {
	depends=""
	pkgdesc="Adapta Eta theme for GNOME"
	install_if="adapta-eta=$pkgver-r$pkgrel gnome"
	_mv Adapta-Eta gnome-shell
}

_adapta_eta_telegram() {
	depends="adapta-telegram"
	pkgdesc="Adapta Eta theme for Telegram"
	install_if="Adapta=$pkgver-r$pkgrel telegram-desktop"
	_mv Adapta-Eta telegram
}

_adapta_nokto() {
	depends="ttf-roboto font-noto"
	pkgdesc="Adapta Nokto theme metapackage"
	mkdir -p "$subpkgdir"
	_mv Adapta-Nokto index.theme
}

_adapta_nokto_gtk3() {
	pkgdesc="Adapta Nokto theme for GTK+3"
	install_if="adapta-nokto=$pkgver-r$pkgrel gtk+3.0"
	_mv Adapta-Nokto gtk-3.0
	_mv Adapta-Nokto gtk-3.22
	_mv Adapta-Nokto gtk-3.24
}

_adapta_nokto_gtk2() {
	depends="gtk-murrine-engine"
	pkgdesc="Adapta Nokto theme for GTK+2"
	install_if="adapta-nokto=$pkgver-r$pkgrel gtk+2.0"
	_mv Adapta-Nokto gtk-2.0
}

_adapta_nokto_openbox() {
	depends=""
	pkgdesc="Adapta Nokto theme for Openbox 3"
	install_if="adapta-nokto=$pkgver-r$pkgrel openbox"
	_mv Adapta-Nokto openbox-3
}

_adapta_nokto_cinnamon() {
	depends=""
	pkgdesc="Adapta Nokto theme for Cinnamon"
	install_if="adapta-nokto=$pkgver-r$pkgrel cinnamon"
	_mv Adapta-Nokto cinnamon
}

_adapta_nokto_gnome() {
	depends="adapta-gnome"
	pkgdesc="Adapta Nokto theme for GNOME Shell"
	install_if="adapta-nokto=$pkgver-r$pkgrel gnome-shell"
	_mv Adapta-Nokto gnome-shell
	_mv Adapta-Nokto gedit
}

_adapta_nokto_telegram() {
	depends=""
	pkgdesc="Adapta Nokto theme for Telegram"
	install_if="adapta-nokto=$pkgver-r$pkgrel telegram-desktop"
	_mv Adapta-Nokto telegram
}

_adapta_nokto_xfwm4() {
	depends="adapta-xfwm4"
	pkgdesc="Adapta Nokto theme for XFCE4 Window Manager"
	install_if="adapta-nokto=$pkgver-r$pkgrel xfwm4"
	_mv Adapta-Nokto xfwm4
}

_adapta_nokto_eta() {
	depends="ttf-roboto font-noto"
	pkgdesc="Adapta Nokto Eta theme metapackage"
	mkdir -p "$subpkgdir"
	_mv Adapta-Nokto-Eta index.theme
}

_adapta_nokto_eta_gtk3() {
	pkgdesc="Adapta Nokto Eta theme for GTK+3"
	install_if="adapta-nokto-eta=$pkgver-r$pkgrel gtk+3.0"
	_mv Adapta-Nokto-Eta gtk-3.0
	_mv Adapta-Nokto-Eta gtk-3.22
	_mv Adapta-Nokto-Eta gtk-3.24
}

_adapta_nokto_eta_gtk2() {
	depends="gtk-murrine-engine"
	pkgdesc="Adapta Nokto Eta theme for GTK+2"
	install_if="adapta-nokto-eta=$pkgver-r$pkgrel gtk+2.0"
	_mv Adapta-Nokto-Eta gtk-2.0
}

_adapta_nokto_eta_gnome() {
	depends=""
	pkgdesc="Adapta Nokto Eta theme for GNOME Shell"
	install_if="adapta-nokto-eta=$pkgver-r$pkgrel gnome-shell"
	_mv Adapta-Nokto-Eta gnome-shell
}

_adapta_nokto_eta_telegram() {
	depends="adapta-nokto-telegram"
	pkgdesc="Adapta Nokto Eta theme for Telegram"
	install_if="adapta-nokto-eta=$pkgver-r$pkgrel telegram-desktop"
	_mv Adapta-Nokto-Eta telegram
}

sha512sums="648f8ad2cf8095c599ff4be4d6d47e0935d6b5bea65c27a36ea69cca89129c59fd078b629a38a048ef300c1bb4ca506c18c4ef0afc9753134894d3a99c83fff1  adapta-gtk-theme-3.95.0.11.tar.gz"
